<template>
  <div class="bg_friend">
    <div class="bg_phone">
      <el-scrollbar class="friend_con">
        <div class="content">
          <div class="bg_top">
            <div class="autor">
              <span class="avar_name">{{ friendlist.name || '张三' }}</span>
              <img class="avator" src="/static/friend.png" alt="" />
            </div>
          </div>
          <div class="other_con" v-if="IsNotEmpty(friendlist)">
            <div class="firend_status">
              <!-- 头像 -->
              <img class="avator_img" src="/static/friend.png" alt="" />
              <div class="firend_r_con">
                <!-- 昵称 -->
                <div class="friend_name">{{ friendlist.name || '张三' }}</div>
                <!-- 标题 -->
                <template v-if="friendlist.type !== 3">
                  <div class="friend_title" v-if="friendlist.type !== 3" v-html="friendlist.content"></div>
                  <div class="friend_title" v-else v-html="friendlist.list[0].title"></div>
                </template>
                <template v-else>
                  <div class="friend_title">{{ friendlist?.content }}</div>
                </template>
                <!-- 链接 -->
                <template v-if="[3, 6, 7, 8, 9].includes(friendlist.type)">
                  <div class="friend_main_con" v-for="item in friendlist.list" :key="item.id">
                    <img class="friend_icon" :src="item.cover_image_url" alt="" />
                    <div class="friend_main_r">
                      <div class="friend_title">{{ item.title }}</div>
                      <div class="friend_desc">{{ item.content }}</div>
                    </div>
                  </div>
                </template>

                <!-- 图片 -->
                <div v-if="friendlist.type == 1" class="friend_pic_box">
                  <template v-if="friendlist.list?.length == 1">
                    <img class="big_image" v-for="item in friendlist.list" :key="item.id" :src="item.absolute_url" alt="" />
                  </template>
                  <template v-else>
                    <img class="small_image" :src="img.absolute_url" alt="" v-for="(img, index) in friendlist.list" :key="index" />
                  </template>
                </div>
                <!-- 视频 -->
                <div v-if="friendlist.type == 2 && IsNotEmpty(friendlist.list)" class="friend_pic_video">
                  <img class="big_image_video" :src="`${friendlist.list[0].absolute_url}?x-oss-process=video/snapshot,t_1000,f_jpg,w_140,h_90,m_fast`" />
                  <div class="cover">
                    <img class="cover_img" src="@/assets/image/friendcirclemat/video_play_icon.png" alt="" />
                  </div>
                </div>
                <div v-if="friendlist.type == 11">
                  <div class="miniApp" v-for="item in friendlist.list" :key="item.id">
                    <div class="mini_box">
                      <img class="mini_icon" src="@/assets/chatDetails/Appletbg.png" alt="" />
                      <div class="miniName">{{ item.name || item.title }}</div>
                    </div>
                    <div class="mini_bg">
                      <el-image :src="item?.imgUrl || item?.cover_image_url" alt="" class="miniImg" fit="contain">
                        <template #error>
                          <div class="image-slot">
                            <img :src="item.cur_icon" alt="" />
                          </div>
                        </template>
                      </el-image>
                    </div>
                    <div class="mini_bot">
                      <img src="@/assets/chatDetails/Applet.png" alt="" />
                      <span>小程序</span>
                    </div>
                  </div>
                </div>
                <!-- 文本 -->
                <!-- <div v-if="friendlist.type==3">
                  {{friendlist.list[0].content}}
                </div> -->
              </div>
            </div>
          </div>
        </div>
      </el-scrollbar>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { reactive, ref, watch } from 'vue'
import { IsNotEmpty } from '@/utils/utils'
/**
 * type 0  文本
 * type 1  图片
 * type 2  视频
 * type 3  链接
 *
 *
 */
let friendlist = ref({})
const props = defineProps(['phoneFriend'])
watch(
  () => props.phoneFriend,
  (data) => {
    console.log(data, '-=-=-=手机显示')
    console.log('data: ', data)
    friendlist.value = data
  },
  { immediate: true }
)
</script>

<style scoped lang="scss">
.bg_friend {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  .bg_phone {
    background: #fff url('/static/bg_phone.png');
    background-size: cover;
    width: 244px;
    height: 495px;
    box-sizing: border-box;
    overflow: hidden;
    // box-shadow: 0px 0.5px 10px rgb(0 0 0 / 20%);
    .friend_con {
      margin: 8px auto;
      width: 225px;
      height: 469px;
      overflow: hidden;
      border-radius: 30px;
      .bg_top {
        width: 100%;
        height: 183px;
        background: url('/static/app/tm.png');
        background-size: cover;
        position: relative;
        .autor {
          position: absolute;
          right: 6px;
          bottom: -10px;
          .avator {
            width: 37px;
            margin-left: 2px;
          }
          .avar_name {
            margin-top: 8px;
            float: left;
            font-size: 12px;
            font-family: STHeitiSC-Medium, STHeitiSC;
            font-weight: 500;
            color: #ffffff;
          }
        }
      }
      .other_con {
        margin: 10px;
        .firend_status {
          display: flex;
          margin-bottom: 10px;
          .avator_img {
            width: 27px;
            height: 27px;
            margin-right: 4px;
          }
          .firend_r_con {
            .friend_name {
              font-size: 12px;
              font-family: STHeitiSC-Medium, STHeitiSC;
              font-weight: 500;
              color: #586b95;
              transform: scale(0.83);
              transform-origin: left top;
              // zoom: 0.83;
            }
            .friend_title {
              width: 150px;
              margin-top: 4px;
              white-space: pre-wrap;
              word-break: break-all;
              font-size: 12px;
              font-family: STHeitiSC-Medium, STHeitiSC;
              font-weight: 500;
              color: #33302d;
              // zoom: 0.83;
              transform: scale(0.83);
              transform-origin: left top;
            }
            .friend_main_con {
              margin-top: 6px;
              padding: 4px;
              background: #f9f9f9;
              width: 170px;
              .friend_icon {
                float: left;
                width: 22px;
                height: 22px;
                margin-right: 4px;
              }
              .friend_main_r {
                overflow: hidden;
                .friend_title {
                  margin-top: 0;
                  font-size: 12px;
                  font-family: STHeitiSC-Medium, STHeitiSC;
                  color: #666;
                  font-weight: 500;
                  margin-bottom: 2px;
                  white-space: nowrap;
                  text-overflow: ellipsis;
                  overflow: hidden;
                  word-break: break-all;
                }
                .friend_desc {
                  font-size: 12px;
                  font-family: STHeitiSC-Medium, STHeitiSC;
                  font-weight: 500;
                  color: #33302d;
                  line-height: 12px;
                  transform: scale(0.83);
                  transform-origin: left top;
                  text-overflow: -o-ellipsis-lastline;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  display: -webkit-box;
                  -webkit-line-clamp: 3;
                  line-clamp: 3;
                  -webkit-box-orient: vertical;
                }
              }

              &:hover {
                background: #fff5f2;
              }
            }
            .friend_pic_video {
              position: relative;
              width: 140px;
              height: 90px;
              .big_image_video {
                width: 140px;
                height: 90px;
              }
              .cover {
                position: absolute;
                width: 100%;
                height: 100%;
                display: flex;
                justify-content: center;
                align-items: center;
                top: 0;
                left: 0;
                background: rgba(0, 0, 0, 0.4);
                img {
                  width: 30px;
                  height: 30px;
                  cursor: pointer;
                }
              }
            }
            .big_image {
              max-width: 120px;
              max-height: 90px;
            }
            .small_image {
              width: 46px;
              height: 46px;
              margin-right: 2px;
              margin-bottom: 1px;
            }
          }
        }
      }
    }
  }
}
.miniApp {
    width: 150px;
    height: 164px;
    background: #ffffff;
    padding: 10px 5px 10px;
    box-sizing: border-box;
    border: 1px solid #eaeaea;
    border-radius: 3px;
    .mini_box {
      display: flex;
      align-items: center;
      margin-bottom: 7px;
      .mini_icon {
        width: 13px;
        height: 13px;
        margin-right: 4px;
      }
    }
    .miniName {
      line-height: 12px;
      font-size: 12px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .mini_bg {
      text-align: center;
      height: 106px;
      padding-bottom: 5px;
      border-bottom: 1px solid #eaeaea;
    }
    .mini_bot {
      line-height: 18px;
      img {
        width: 8px;
        height: 7px;
      }
      span {
        display: inline-block;
        font-size: 12px;
        transform: scale(0.68);
      }
    }
    .miniImg {
      width: 100%;
      height: 106px;
      margin: 0 auto;
    }
  }
</style>
